/*
* @Author: Choisaaaa
* @Date: 2018/5/8  0:09
*/

var _mm = require("util/mm.js");

var _uploadImg = {

    uploadImage : function(formData,resolve,reject) {
        var _this = this,
            url =  _mm.getServerUrl("/image/upload.do") ;
        $.ajax({
            type : "post" ,
            url : url ,
            processData : false,
            contentType : false,
            xhrFields:{
                withCredentials: true
            },
            crossDomain: true,
            data : formData ,
            success : function(res){
                if(0 === res.status){
                    typeof resolve === "function" && resolve(res);
                }
                else if(-1 === res.state){
                    typeof reject === "function" && reject(res);
                }
                else if(i === res.state){
                    typeof reject === "function" && reject(res);
                }
            },
            error : function(err){
                typeof reject === "function" && reject(err);
            }
        });

    },

}


module.exports = _uploadImg;